    //
//  PassengerViewController.m
//  Untitled
//
//  Created by zou leeging on 11-1-8.
//  Copyright 2011 apple. All rights reserved.
//

#import "PassengerViewController.h"


@implementation PassengerViewController

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
	return YES;
}
-(void)didGetIDkind:(NSString *)idKind {

	UIButton *button = (UIButton *)[self.view viewWithTag:200];
	[button setTitle:idKind forState:UIControlStateNormal];
}

// mplement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	[super loadView];
	
	//	clientSocket = [[CWSocketByStream alloc] init];
	//	[clientSocket createStream:@"58.247.98.94" serverPort:7000];
	
	UIBarButtonItem *reg = [[UIBarButtonItem alloc]initWithTitle:@"完成" 
														   style:UIBarButtonItemStylePlain 
														  target:self 
														  action:@selector(toRegister)];
	self.navigationItem.rightBarButtonItem = reg;
	[reg release];
	
	UIImage *img = [UIImage imageNamed:@"loginback"];
	UIImageView *regBack = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, img.size.width, img.size.height)];
	regBack.image = img;
	[self.view addSubview:regBack];
	[regBack release];
	
	UIScrollView *content = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
	content.contentSize = CGSizeMake(320, 650);
	content.scrollEnabled = YES;
	[self.view addSubview:content];
	[content release];
	
	UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 15, 90, 20)];
	label.text = @"姓名";
	[label setTag:1];
	label.font = [UIFont systemFontOfSize:13];
	label.textAlignment = UITextAlignmentRight;
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	nameText = [[UITextField alloc]initWithFrame:CGRectMake(100, 15, 100, 20)];
	nameText.borderStyle = UITextBorderStyleRoundedRect;
	nameText.returnKeyType = UIReturnKeyDone;
	nameText.delegate = self;
	[content addSubview:nameText];
	[nameText release];
	
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 60, 90, 20)];
	label.text = @"性别(必选)";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	UISegmentedControl *sex = [[UISegmentedControl alloc]initWithItems:nil];
	sex.frame = CGRectMake(100, 60, 100, 20);
	[sex setTag:900];
	sex.segmentedControlStyle = UISegmentedControlStylePlain;
	sex.tintColor = [UIColor colorWithRed:0.75 green:1.0 blue:0.75 alpha:1.0];
	[sex insertSegmentWithTitle:@"男" atIndex:0 animated:NO];
	[sex insertSegmentWithTitle:@"女" atIndex:1 animated:NO];
	sex.selectedSegmentIndex = 0;
	sexSelection = @"1";
	[sex addTarget:self action:@selector(selectSex) forControlEvents:UIControlEventValueChanged];
	[content addSubview:sex];
	[sex release];
	
	
	//---------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 105, 90, 20)];
	label.text = @"证件类型";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	UIImage *image = [UIImage imageNamed:@"IDkind.png"];
	UIButton *IDkind = [[UIButton alloc]initWithFrame:CGRectMake(100, 105, 100, 20)];
	[IDkind setBackgroundImage:image forState:UIControlStateNormal];
	[IDkind setTag:200];
	[IDkind setTitle:@"身份证" forState:UIControlStateNormal];
	[IDkind addTarget:self action:@selector(whatIsKind) forControlEvents:UIControlEventTouchUpInside];
	[content addSubview:IDkind];
	[IDkind release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 150, 90, 20)];
	label.text = @"证件号码";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	email = [[UITextField alloc]initWithFrame:CGRectMake(100, 150, 100, 20)];
	email.borderStyle = UITextBorderStyleRoundedRect;
	email.returnKeyType = UIReturnKeyDone;
	email.delegate = self;
	[content addSubview:email];
	[email release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 195, 90, 20)];
	label.text = @"国家代号";
	label.textAlignment = UITextAlignmentRight;
	
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	cellphone = [[UITextField alloc]initWithFrame:CGRectMake(100, 195, 100, 20)];
	cellphone.borderStyle = UITextBorderStyleRoundedRect;
	cellphone.returnKeyType = UIReturnKeyDone;
	cellphone.delegate = self;
	[content addSubview:cellphone];
	[cellphone release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 240, 90, 20)];
	label.text = @"保险";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	UISwitch *baoxian = [[UISwitch alloc]initWithFrame:CGRectMake(100, 240, 50, 15)];
	baoxian.on = YES;
	[baoxian setTag:100];
	[content addSubview:baoxian];
	[baoxian addTarget:self action:@selector(needBaoxian) forControlEvents:UIControlEventValueChanged];
	[baoxian release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 285, 90, 20)];
	label.text = @"保险金额";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	baoxianfei = [[UITextField alloc]initWithFrame:CGRectMake(100, 285, 100, 20)];
	baoxianfei.borderStyle = UITextBorderStyleRoundedRect;
	baoxianfei.returnKeyType = UIReturnKeyDone;
	baoxianfei.delegate = self;
	[content addSubview:baoxianfei];
	[baoxianfei release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 330, 90, 20)];
	label.text = @"乘客类型";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	telephone = [[UITextField alloc]initWithFrame:CGRectMake(100, 330, 100, 20)];
	telephone.borderStyle = UITextBorderStyleRoundedRect;
	telephone.returnKeyType = UIReturnKeyDone;
	telephone.delegate = self;
	[content addSubview:telephone];
	[telephone release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 375, 90, 20)];
	label.text = @"常旅客卡号";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	payaddress = [[UITextField alloc]initWithFrame:CGRectMake(100, 375, 100, 20)];
	payaddress.borderStyle = UITextBorderStyleRoundedRect;
	payaddress.returnKeyType = UIReturnKeyDone;
	payaddress.delegate = self;
	[content addSubview:payaddress];
	[payaddress release];
	//---------------------------------------------
	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 420, 90, 20)];
	label.text = @"出生日期";
	label.textAlignment = UITextAlignmentRight;
	label.font = [UIFont systemFontOfSize:13];
	label.backgroundColor = [UIColor clearColor];
	[content addSubview:label];
	[label release];
	
	postcode = [[UITextField alloc]initWithFrame:CGRectMake(100, 420, 100, 20)];
	postcode.borderStyle = UITextBorderStyleRoundedRect;
	postcode.returnKeyType = UIReturnKeyDone;
	postcode.delegate = self;
	[content addSubview:postcode];
	[postcode release];
//	//---------------------------------------------
//	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 465, 90, 20)];
//	label.text = @"密码保护问题1";
//	label.textAlignment = UITextAlignmentRight;
//	label.font = [UIFont systemFontOfSize:13];
//	label.backgroundColor = [UIColor clearColor];
//	[content addSubview:label];
//	[label release];
//	
//	question1 = [[UITextField alloc]initWithFrame:CGRectMake(100, 465, 210, 20)];
//	question1.borderStyle = UITextBorderStyleRoundedRect;
//	question1.returnKeyType = UIReturnKeyDone;
//	question1.delegate = self;
//	[content addSubview:question1];
//	[question1 release];
//	//---------------------------------------------
//	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 510, 90, 20)];
//	label.text = @"答案1";
//	label.textAlignment = UITextAlignmentRight;
//	label.font = [UIFont systemFontOfSize:13];
//	label.backgroundColor = [UIColor clearColor];
//	[content addSubview:label];
//	[label release];
//	
//	answer1 = [[UITextField alloc]initWithFrame:CGRectMake(100, 510, 100, 20)];
//	answer1.borderStyle = UITextBorderStyleRoundedRect;
//	answer1.returnKeyType = UIReturnKeyDone;
//	answer1.delegate = self;
//	[content addSubview:answer1];
//	[answer1 release];
//	//---------------------------------------------
//	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 555, 90, 20)];
//	label.text = @"密码保护问题2";
//	label.textAlignment = UITextAlignmentRight;
//	label.font = [UIFont systemFontOfSize:13];
//	label.backgroundColor = [UIColor clearColor];
//	[content addSubview:label];
//	[label release];
//	
//	question2 = [[UITextField alloc]initWithFrame:CGRectMake(100, 555, 210, 20)];
//	question2.borderStyle = UITextBorderStyleRoundedRect;
//	question2.returnKeyType = UIReturnKeyDone;
//	question2.delegate = self;
//	[content addSubview:question2];
//	[question2 release];
//	//---------------------------------------------
//	label = [[UILabel alloc]initWithFrame:CGRectMake(5, 600, 90, 20)];
//	label.text = @"答案2";
//	label.textAlignment = UITextAlignmentRight;
//	label.font = [UIFont systemFontOfSize:13];
//	label.backgroundColor = [UIColor clearColor];
//	[content addSubview:label];
//	[label release];
//	
//	answer2 = [[UITextField alloc]initWithFrame:CGRectMake(100, 600, 210, 20)];
//	answer2.borderStyle = UITextBorderStyleRoundedRect;
//	answer2.returnKeyType = UIReturnKeyDone;
//	answer2.delegate = self;
//	[content addSubview:answer2];
//	[answer2 release];
	//---------------------------------------------
	
}

-(void)selectSex {
	
}
-(void)whatIsKind {

	IDKindViewController *controller = [[IDKindViewController alloc]init];
	[self.navigationController pushViewController:controller animated:YES];
	controller.delegate = self;
	[controller release];
}

-(void)needBaoxian {

	UISwitch *baoxian = (UISwitch *)[self.view viewWithTag:100];
	
	if (baoxian.on == YES) {
		baoxianfei.enabled = YES;
	}
	else {
		baoxianfei.enabled = NO;
	}

	
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

	
}
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
